package com.yanqu.road.server.cmd.strongholdwar;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.StrongholdWarCrossProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.strongholdwar.StrongholdWarMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C_CROSS_STRONGHOLD_TRADE,desc = "")
public class CrossStrongholdTradeCmd extends CrossUnionCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        StrongholdWarCrossProto.UploadTradeMsg msg = StrongholdWarCrossProto.UploadTradeMsg.parseFrom(packet.getBytes());
        int activityId = msg.getActivityId();
        long userId = msg.getUserId();
        String unionId = msg.getUnionId();
        UserBaseInfo userBaseInfo = PlayerBasePb.parseBaseUserInfo(msg.getPlayerBaseData());
        CrossUserMgr.updateUserBaseInfo(userId,userBaseInfo);
        StrongholdWarMgr.addTrade(activityId, userId, unionId);
    }

    @Override
    public void sendData() {

    }
}
